//
//  SettingCell.m
//  ProjectSource_Demo
//
//  Created by Liu on 16/3/24.
//  Copyright © 2016年 AngryBear. All rights reserved.
//

#import "SettingCell.h"

@implementation SettingCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.rightArrow];
        [self.contentView addSubview:self.rightLabel];
        [self.contentView addSubview:self.switchView];
        [self.contentView addSubview:self.bottomLine];
        
        self.titleLabel.hidden = YES;
        self.rightArrow.hidden = YES;
        self.rightArrow.hidden = YES;
        self.switchView.hidden = YES;
        
        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.top.mas_equalTo(@15);
        }];
        
        [self.rightArrow mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(@15);
            make.right.mas_equalTo(@(-15));
        }];
        
        [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.titleLabel);
            make.right.mas_equalTo(@(-15));
        }];
        
        [self.switchView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(self.titleLabel);
            make.right.mas_equalTo(@(-15));
        }];
        
        [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(@15);
            make.right.mas_equalTo(@(-15));
            make.height.mas_equalTo(@2);
            make.bottom.equalTo(self.contentView);
        }];
    }
    return self;
}


#pragma mark - Getter Methods
- (UIView *)bottomLine
{
    if (_bottomLine == nil) {
        _bottomLine = [[UIView alloc] initWithFrame:CGRectZero];
        _bottomLine.backgroundColor = [UIColor colorWithHexRGB:0xf5f5f5];
    }
    return _bottomLine;
}

- (UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
        label.backgroundColor = [UIColor clearColor];
        label.textColor = [UIColor colorWithHexRGB:0x606060];
        label.font = [UIFont systemFontOfSize:15];
        label.textAlignment = NSTextAlignmentLeft;
        _titleLabel = label;
    }
    return _titleLabel;
}

- (UIImageView *)rightArrow
{
    if (_rightArrow == nil) {
        _rightArrow = [[UIImageView alloc] initWithFrame:CGRectZero];
        _rightArrow.image = [UIImage imageNamed:@"rightArrow_deep"];
    }
    return _rightArrow;
}

- (UILabel *)rightLabel
{
    if (_rightLabel == nil) {
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
        label.backgroundColor = [UIColor clearColor];
        label.textColor = [UIColor colorWithHexRGB:0x606060];
        label.font = [UIFont systemFontOfSize:15];
        label.textAlignment = NSTextAlignmentRight;
        _rightLabel = label;
    }
    return _rightLabel;
}

- (UISwitch *)switchView
{
    if (_switchView == nil) {
        _switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
    }
    return _switchView;
}

@end
